package MathTextModeller
{
	import MathText.WordProblem;
	
	import MyDisplayObjects.ClickableMC;
	
	import flash.display.MovieClip;
	
	/** An object that allows multiple buttons to be displayed and selected. Will be extended for specific sets of tools.*/
	public class ToolFace extends MovieClip
	{
		protected var color:uint, lineColor:uint;
		protected var sentenceToolsXML:XML; // the tools that are associated with this combine, change, or compare sentence
		protected var buttons:Array;
		protected var wordProblem:WordProblem;
		protected var WIDTH:Number, HEIGHT:Number // the permanent width and height
		// publicly accessible by getter
		protected var _type:String;
		// getters and setters
		public function get type():String{return _type;}
		
		public function ToolFace(width:Number, height:Number, color:uint, sentenceToolsXML:XML, wordProblem:WordProblem)
		{
			this.color = color;
			this.sentenceToolsXML = sentenceToolsXML;
			this.wordProblem = wordProblem;
			var r:int, g:int, b:int;
			// get dark color for unselectedColor
			r = color & 0xFF0000; r = r >> 16;
			g = color & 0x00FF00; g = g >> 8;
			b = color & 0x0000FF;
			var dr:int = r-r/8; if (dr < 0) dr = 0;
			var dg:int = g-g/8; if (dg < 0) dg = 0;
			var db:int = b-b/8; if (db < 0) db = 0;
			lineColor = dr << 16 | dg << 8 | db;
			WIDTH = width;
			HEIGHT = height;
			this.graphics.lineStyle(width/100, lineColor);
			this.graphics.beginFill(color);
			this.graphics.drawRoundRect(0, 0, width, height, Math.min(width/12, height/12),  Math.min(width/12, height/12));
			this.graphics.endFill();
			
		}
		/** Searches through list of buttons and enables given one */
		public function enableButton(name:String):Boolean
		{
			if (buttons != null)
			{
				for each (var b:ClickableMC in buttons)
				{
					if (b.name == name)
					{
						b.disabled = false;
						return true;
					}
				}
			}
			return false;
		}
	}
}